#include <stdio.h>

int main()
{
    FILE *file = fopen("user.txt", "a+");
    if (file == NULL)
    {
        printf("打开文件失败\n");
    }
    else
    {
        printf("打开文件成功(%p)\n", file);
    }

    char name[50];
    char wife[50];
    int age;
    while (fscanf(file, "%s %s %d", name, wife, &age)!=EOF)
    {
        printf("%s在%d时爱上了%s\n", name, age, wife);
    }

    int fclose_ret = fclose(file);
    if (fclose_ret == 0)
    {
        printf("关闭文件成功\n");
    }
    else
    {
        printf("关闭文件失败\n");
    }
    return 0;
}